package P1300;

import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-08 18:43
 */
public class P1308_统计单词数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String word = scanner.nextLine().toLowerCase();
        String input = scanner.nextLine();
        scanner.close();
        String[] words = input.split(" ");
        int match = 0;
        int index = 0;
        for(int i=0;i<words.length;++i){
            if(words[i].toLowerCase().equals(word)){
                ++match;
            }else{//没有匹配上
                if(match == 0) index += words[i].length()+1;//还有一个空格
            }
        }
        if(match == 0) System.out.println(-1);
        else{
            System.out.printf("%d %d",match,index);
        }
    }
}
